package com.example.demo.entity.vo;

import java.time.LocalDateTime;

/**
 * 验证码实体类，存储验证码信息
 */

public class CaptchVo {

    String code;//验证码内容
    LocalDateTime expireTime;//过期时间

    /**
     *
     * @param code 验证码内容
     * @param expireSeconds 过期秒数
     */
    public CaptchVo(String code, int  expireSeconds) {
        this.code = code;
        this.expireTime=LocalDateTime.now().plusSeconds(expireSeconds);
    }

    /**
     * 验证码是否过期
     * @return
     */
    public boolean isExpired(){
       return  LocalDateTime.now().isAfter(expireTime);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public LocalDateTime getExpireTime() {
        return expireTime;
    }


    public void setExpireTime(LocalDateTime expireTime) {
        this.expireTime = expireTime;
    }
}
